
$(function () {
    $(".update-money-btn").click(function (event) {
        var self = $(this);
        var dialog = $('#money-dialog');
        dialog.modal('show');

        var tr = self.parent().parent();
        // var proportion = tr.attr("data-proportion");
        var price = tr.attr("data-price");
        // var trend = tr.attr("data-trend");

        var priceInput = $("input[name='price']");
        // var usdtInput = $("input[name='usdt']");
        // var trendInput = $("input[name='trend']");
        var savebtn = dialog.find("#save-money-btn");

        priceInput.val(price);
        savebtn.attr("data-type",'update');
        savebtn.attr("data-id",tr.attr('data-id'));
    })
})


$(function () {
    $('#save-money-btn').click(function (event) {
        event.preventDefault();
        var self = $(this);
        var dialog = $('#money-dialog');

        var price = $("input[name='price']").val();
        var submitType = self.attr("data-type");
        var money_id = self.attr('data-id');

        zlalert.alertConfirm({
            'msg':'您确定要修改价格(数量)吗？此操作会生成一条记录，请谨慎操作！',
            'confirmCallback':function () {
                zlajax.post({
                    'url':'/cms/update_money_manage/',
                    'data':{
                        'price': price,
                        'money_id': money_id,
                    },
                    'success':function (data) {
                        dialog.modal('hide');
                        if(data['code']==200){
                            window.location.reload()
                        }else{
                            zlalert.alertInfo(data['message']);
                        }
                    },
                    'fail':function () {
                        zlalert.alertNetworkError();
                    }
                })
            }
        })

    })
});

